package moc;

public class EnumDemo {
    public static void main(String[] args) {
//        获取枚举项名称
        String name = Season.SPRING.name();
        System.out.println(name);

//        返回枚举项在枚举类中的索引值
        int ordinal = Season.SUMMER.ordinal();
        System.out.println(ordinal);

//        比较两个枚举项，返回的是索引值的差值
        int index = Season.SPRING.compareTo(Season.WINTER);
        System.out.println(index);

//        返回枚举常量的名称
        String s = Season.SPRING.toString();
        System.out.println(s);

//        获取指定枚举类中的指定名称的枚举值
        Season autumn = Enum.valueOf(Season.class, "AUTUMN");
        System.out.println(autumn);
        System.out.println(Season.AUTUMN == autumn);

//        获得所有的枚举项
        Season[] values = Season.values();
        for (Season value : values) {
            System.out.println(value);
        }

    }
}
